package org.iks.common.aop.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.iks.common.enums.ChatMessageType;

import java.io.IOException;

/**
 * Author kzou
 * Date 2024/3/23
 * Description: 自定义Json序列化
 *
 * @see ChatMessageType
 */
public class ChatMessageTypeSerializer extends JsonSerializer<ChatMessageType> {

    @Override
    public void serialize(
            ChatMessageType chatMessageType,
            JsonGenerator jsonGenerator,
            SerializerProvider serializerProvider) throws IOException {
        jsonGenerator.writeNumber(chatMessageType.getCode());
    }

}
